package com.aaa.entity;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;

/**
 * 公司地点和考勤配置
 */
@Data
@Component
@ConfigurationProperties(prefix = "work-attendance-config")
public class WorkAttendanceConfig {
    private Long id;//主键
    private Double companyLatitude;//公司纬度
    private Double companyLongitude;//公司经度
    private Integer internalCheckRange;//有效打卡范围（单位：米）
    private String workStartTime;//上班时间
    private String workEndTime;//下班时间
    private Boolean enabled;//是否启用考勤配置
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;//创建时间
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;//更新时间
//    TODO 管理系统配置打卡设置

    // 添加方法将字符串转换为 LocalTime
    public LocalTime getWorkStartTimeAsLocalTime() {
        return LocalTime.parse(workStartTime, DateTimeFormatter.ofPattern("HH:mm"));
    }

    public LocalTime getWorkEndTimeAsLocalTime() {
        return LocalTime.parse(workEndTime, DateTimeFormatter.ofPattern("HH:mm"));
    }
}
